Este documento contiene visualización de datos elaborado con lo paquetes ggplot2 y plotly de R.
Carga de paquetes
Código
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.2 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.2 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Código
library(plotly)
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
Código
library(DT)library(gapminder)
Carga de Datos
mpg
Código
# Despliegue de los datos mpg mpg |>datatable(options =list(pageLength =5,language =list(url ='//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json') ) )
diamonds
Código
# Carga de datos de diamondsdiamonds |>datatable(options =list(pageLength =5,language =list(url ='//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json') ) )
gapminder
Código
# Carga de datos de gapmindergapminder |>filter(year ==2007) |>datatable(options =list(pageLength =5,language =list(url ='//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json') ) )
Covid
Código
# Carga del archivo CSV de entrada en un dataframe# con la función read_delim() de readrcovid_general <-read_delim(file ="https://raw.githubusercontent.com/gf0604-procesamientodatosgeograficos/2023-i/main/datos/ministerio-salud/covid/05_30_22_CSV_GENERAL.csv",col_select =c("FECHA","positivos","activos","RECUPERADOS","fallecidos","nue_posi","nue_falleci","salon","UCI" ) )# Cambio de nombre de columnascovid_general <- covid_general |>rename(fecha = FECHA,recuperados = RECUPERADOS,nuevos_positivos = nue_posi,nuevos_fallecidos = nue_falleci,uci = UCI )# Cambio de tipo de datos de la columna fecha, de str a datecovid_general <- covid_general |>mutate(fecha =as.Date(fecha, format ="%d/%m/%Y"))# Tabla de datos de COVID generalescovid_general |>datatable(options =list(pageLength =5,language =list(url ='//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json') ) )
delitpos
Código
# Carga de datosdelitos_2022 <-read_delim(file ="https://raw.githubusercontent.com/gf0604-procesamientodatosgeograficos/2023-i/main/datos/oij/estadisticas-policiales/estadisticaspoliciales2022.csv" )
Rows: 96651 Columns: 12
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (12): Delito, SubDelito, Fecha, Hora, Victima, SubVictima, Edad, Genero,...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Código
# Tabla de datosdelitos_2022 |>datatable(options =list(pageLength =5,language =list(url ='//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json') ) )
Warning in instance$preRenderHook(instance): It seems your data is too big for
client-side DataTables. You may consider server-side processing:
https://rstudio.github.io/DT/server.html